<template>
	<div>
		<el-dialog
		        :title="addTitle"
				@close="$emit('confirm')"
				:close-on-click-modal="false"
		        :visible.sync="formShow"
		        width="1000px"
		>
		  <div>
			  <el-form ref="form" label-width="80px">
				  <el-form-item label="品牌名称">
				  		<selectBrand ref="selectBrand1" 
							@getBrandName="getBrandName" />
						<!-- <el-input size="small"
							v-if="form.id"
							disabled
							v-model="form.brand_name"
						></el-input> -->
				  </el-form-item>
				  <el-form-item label="系列名称">
						 <el-input size="small" 
							v-model="form.class_name"
						 ></el-input>
				  </el-form-item>
				  <el-form-item label="系列说明">
						<el-input type="textarea" size="small" v-model="form.class_remark"
						></el-input>
				  </el-form-item>
				  <el-form-item label="系列排序">
				  		<el-input v-model="form.sort" type="number" 
				  			size="small"></el-input>
				  </el-form-item>
				  <el-form-item >
				      <el-button type="primary" @click="confirm" size="small">确定</el-button>
				  </el-form-item>
			  </el-form>
		  </div>
		</el-dialog>
	</div>
</template>

<script>
	import selectSerial from '@/components/selectSerial.vue'
	import selectBrand from '@/components/selectBrand.vue'
	export default {
		components:{
			selectSerial,selectBrand
		},
		data(){
			return {
				form:{
					id:null,
					class_remark:'',
					class_name:'',
					brand_name:"",
					old_class_name:'',
					old_brand_name:'',
					sort:1
				},
				addTitle:'新增',
				table_name:'hs_class',
				formShow:true
			}
		},
		methods:{
			getClassName(val){
				
				this.form.class_name = val
			},
			getBrandName(val){
				this.form.brand_name = val
				this.$refs.selectSerial.lodeClass(val)
			},
			confirm(){
				let url
				if(this.form.id){
					url = '/prodectSys/editClass'
				}else{
					url = '/prodectSys/addCate'
				}
				
				this.$post(url,this.form,res=>{
					if(res.data.code==200){
						this.$message.success('操作成功')
						this.formShow = false
						this.$emit('confirm')
					}
				})
			},
		}
	}
</script>

<style>
</style>